﻿USE [Plato]
GO
/****** Objet :  Role [Admin]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE ROLE [LaborAdmin]
GO
/****** Objet :  Role [LaborReader]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE ROLE [LaborReader]
GO
/****** Objet :  Role [LaborUser]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE ROLE [LaborUser]
GO
/****** Objet :  Role [Designer]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE ROLE [LaborDesigner]
GO
/****** Objet :  Role [SP_Executor]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE ROLE [SP_Executor]
GO
/****** Objet :  User [plato]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE USER [plato] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Objet :  User [LabDesigner]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE LOGIN [LabDesigner] WITH PASSWORD = 'agpase';
CREATE USER [Designer] FOR LOGIN [LabDesigner] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Objet :  User [LabAdmin]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE LOGIN [LabAdmin] WITH PASSWORD = 'glucose';
CREATE USER [LabAdmin] FOR LOGIN [LabAdmin] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Objet :  User [lab]    Date de génération du script : 09/23/2013 11:46:31 ******/
CREATE LOGIN [lab] WITH PASSWORD = 'enzyme';
CREATE USER [lab] FOR LOGIN [lab] WITH DEFAULT_SCHEMA=[dbo]
GO






/****** Objet :  Table [dbo].[Parameter]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Parameter](
	[UId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Parameter_UId]  DEFAULT (newid()),
	[Name] [nvarchar](50) NOT NULL,
	[Datatype] [nvarchar](50) NOT NULL,
	[Description] [nvarchar](max) NULL,
	[Unit] [nvarchar](50) NULL,
	[IsSplitVariable] [bit] NOT NULL CONSTRAINT [DF_Parameter_IsSplitVariable]  DEFAULT ((0)),
 CONSTRAINT [PK_Parameter] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[Unit]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Unit](
	[UId] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Unit] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Unit] UNIQUE NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  StoredProcedure [dbo].[sp_helproleember2]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[sp_helproleember2]
	@user       sysname = NULL
AS
	if @user is not null
	begin
		-- VALIDATE GIVEN NAME
	

		-- RESULT SET FOR SINGLE ROLE
		select DbRole = g.name, MemberName = u.name, MemberSID = u.sid
			from sys.database_principals u, sys.database_principals g, sys.database_role_members m
			where u.name = @user
				and g.principal_id = m.role_principal_id
				and u.principal_id = m.member_principal_id
			order by 1, 2
	end
	else
	begin
		-- RESULT SET FOR ALL ROLES
		select DbRole = g.name, MemberName = u.name, MemberSID = u.sid
			from sys.database_principals u, sys.database_principals g, sys.database_role_members m
			where   g.principal_id = m.role_principal_id
				and u.principal_id = m.member_principal_id
			order by 1, 2
	end

	return (0) -- sp_helprolemember
GO
/****** Objet :  StoredProcedure [dbo].[SelectPersons]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
/****** Object:  Stored Procedure dbo.SelectPersons    Script Date: 15.06.2006 14:50:14 ******/
CREATE PROCEDURE [dbo].[SelectPersons] AS

select * from Persons
GO
/****** Objet :  Table [dbo].[EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EnzymeCode](
	[UId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_EnzymeCode_UId]  DEFAULT (newid()),
	[Analyte] [nvarchar](50) NOT NULL,
	[SlopeRatio] [float] NOT NULL,
	[Code] [nvarchar](50) NOT NULL,
	[Type] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_EnzymeCodes] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_EnzymeCode] UNIQUE NONCLUSTERED 
(
	[Analyte] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_EnzymeName] UNIQUE NONCLUSTERED 
(
	[Analyte] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  StoredProcedure [dbo].[SelectEnzymeActivity]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.SelectEnzymeActivity    Script Date: 15.06.2006 14:50:13 ******/

CREATE  PROCEDURE [dbo].[SelectEnzymeActivity]
(
	@Material nvarchar (50)
)
AS
	
select Enzyme, SlopeRatio, Value, Material_Fk  from dbo.EnzymeCodes, dbo.Activity
where Enzyme = EnzymeCode_Fk and Material_Fk = @Material
GO
/****** Objet :  Table [dbo].[Material]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Material](
	[UId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Material_UId]  DEFAULT (newid()),
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Material] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Material] UNIQUE NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[ProtocolSetting]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProtocolSetting](
	[Protocol_Fk] [uniqueidentifier] NOT NULL,
	[Parameter_Fk] [uniqueidentifier] NOT NULL,
	[Value] [nvarchar](50) NULL,
	[SplitValue] [nvarchar](50) NULL,
 CONSTRAINT [PK_ProtocolSetting] PRIMARY KEY CLUSTERED 
(
	[Protocol_Fk] ASC,
	[Parameter_Fk] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[Activity]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Activity](
	[EnzymeCode_Fk] [uniqueidentifier] NOT NULL,
	[Material_Fk] [uniqueidentifier] NOT NULL,
	[Protocol_Fk] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Activity_Protocol_Fk]  DEFAULT (CONVERT([uniqueidentifier],'00000000-0000-0000-0000-000000000000',(0))),
	[Value] [float] NULL,
	[Unit_Fk] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Activity] PRIMARY KEY CLUSTERED 
(
	[EnzymeCode_Fk] ASC,
	[Material_Fk] ASC,
	[Protocol_Fk] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[Protocol]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Protocol](
	[UId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Protocol_UId]  DEFAULT (newid()),
	[Name] [nvarchar](50) NOT NULL,
	[Description] [nvarchar](max) NULL,
	[Enzyme_Fk] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Protocol] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Protocol] UNIQUE NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[RawData]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RawData](
	[BatchName_Fk] [nvarchar](50) NOT NULL,
	[BatchNumber_Fk] [int] NOT NULL,
	[BatchDate_Fk] [datetime] NOT NULL,
	[Row_Fk] [int] NOT NULL,
	[Column_Fk] [int] NOT NULL,
	[RawValue] [float] NOT NULL,
	[Velocity] [nvarchar](50) NOT NULL,
	[Enzyme_Fk] [uniqueidentifier] NOT NULL,
	[proved] [bit] NOT NULL CONSTRAINT [DF_RawData_proved]  DEFAULT ((0)),
	[excluded] [bit] NOT NULL CONSTRAINT [DF_RawData_excluded]  DEFAULT ((0)),
 CONSTRAINT [PK_RawData] PRIMARY KEY CLUSTERED 
(
	[BatchName_Fk] ASC,
	[BatchNumber_Fk] ASC,
	[BatchDate_Fk] ASC,
	[Row_Fk] ASC,
	[Column_Fk] ASC,
	[Velocity] ASC,
	[Enzyme_Fk] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[ProcessedData]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProcessedData](
	[BatchName_Fk] [nvarchar](50) NOT NULL,
	[BatchNumber_Fk] [int] NOT NULL,
	[BatchDate_Fk] [datetime] NOT NULL,
	[Enzyme_Fk] [uniqueidentifier] NOT NULL,
	[Row_Fk] [int] NOT NULL,
	[Column_Fk] [int] NOT NULL,
	[Value] [float] NULL,
 CONSTRAINT [PK_ProcessedData] PRIMARY KEY CLUSTERED 
(
	[BatchName_Fk] ASC,
	[BatchNumber_Fk] ASC,
	[BatchDate_Fk] ASC,
	[Enzyme_Fk] ASC,
	[Row_Fk] ASC,
	[Column_Fk] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[BatchCompilation]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BatchCompilation](
	[BatchName_Fk] [nvarchar](50) NOT NULL,
	[BatchNumber_Fk] [int] NOT NULL,
	[BatchDate_Fk] [datetime] NOT NULL,
	[Experiment_Fk] [nvarchar](50) NOT NULL,
	[Sample_Fk] [int] NOT NULL,
	[Aliquot_Fk] [int] NOT NULL,
	[Row] [int] NOT NULL,
	[Column] [int] NOT NULL,
 CONSTRAINT [PK_BatchCompilation] PRIMARY KEY CLUSTERED 
(
	[BatchName_Fk] ASC,
	[BatchNumber_Fk] ASC,
	[BatchDate_Fk] ASC,
	[Row] ASC,
	[Column] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[FreshWeights]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FreshWeights](
	[UId] [uniqueidentifier] NOT NULL,
	[Experiment_FK] [nvarchar](50) NOT NULL,
	[Sample] [int] NOT NULL,
	[Aliquot] [int] NOT NULL,
	[Value] [float] NULL,
	[Location] [nvarchar](500) NULL,
 CONSTRAINT [PK_FreshWeights2] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_FreshWeights] UNIQUE NONCLUSTERED 
(
	[Experiment_FK] ASC,
	[Sample] ASC,
	[Aliquot] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[Batches]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Batches](
	[UId] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Number] [int] NOT NULL,
	[Date] [datetime] NOT NULL,
	[LayoutType] [nvarchar](50) NOT NULL CONSTRAINT [DF_Batches_LayoutType]  DEFAULT (N'SPLIT'),
	[RowCount] [int] NOT NULL,
	[ColumnCount] [int] NOT NULL,
	[Protocol_Fk] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Batches_Protocol_Fk]  DEFAULT ('00000000-0000-0000-0000-000000000000'),
 CONSTRAINT [PK_Batches] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Batches] UNIQUE NONCLUSTERED 
(
	[Name] ASC,
	[Number] ASC,
	[Date] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  Table [dbo].[Experiments]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Experiments](
	[UId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Experiments_UId]  DEFAULT (newid()),
	[Id] [nvarchar](50) NOT NULL,
	[Material_Fk] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Experiments] PRIMARY KEY CLUSTERED 
(
	[UId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Experiments] UNIQUE NONCLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Objet :  View [dbo].[ParameterView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ParameterView]
AS
SELECT     UId, Name, Datatype, Description, Unit, IsSplitVariable
FROM         Parameter
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Parameter"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 198
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ParameterView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ParameterView'
GO
/****** Objet :  View [dbo].[ProtocolSettingView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ProtocolSettingView]
AS
SELECT     Protocol.UId AS ProtocolUId, Protocol.Name AS ProtocolName, Parameter.UId AS ParameterUId, Parameter.Name AS ParameterName, 
                      Parameter.Datatype AS ParameterDataType, Parameter.Description AS ParameterDescription, Parameter.Unit AS ParameterUnit, 
                      Parameter.IsSplitVariable AS ParameterIsSplitVariable, ProtocolSetting.Value, ProtocolSetting.SplitValue
FROM         ProtocolSetting INNER JOIN
                      Protocol ON ProtocolSetting.Protocol_Fk = Protocol.UId INNER JOIN
                      Parameter ON ProtocolSetting.Parameter_Fk = Parameter.UId
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "ProtocolSetting"
            Begin Extent = 
               Top = 69
               Left = 308
               Bottom = 165
               Right = 460
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Protocol"
            Begin Extent = 
               Top = 69
               Left = 578
               Bottom = 165
               Right = 730
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Parameter"
            Begin Extent = 
               Top = 63
               Left = 56
               Bottom = 189
               Right = 208
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 3540
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ProtocolSettingView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ProtocolSettingView'
GO
/****** Objet :  View [dbo].[ActivityView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ActivityView]
AS
SELECT     dbo.EnzymeCode.UId AS EnzymeUid, dbo.EnzymeCode.Analyte, dbo.EnzymeCode.Type, dbo.EnzymeCode.SlopeRatio, dbo.EnzymeCode.Code, 
                      dbo.Material.UId AS MaterialUId, dbo.Material.Name AS Material, dbo.Protocol.UId AS ProtocolUId, dbo.Protocol.Name AS Protocol, dbo.Protocol.Description, 
                      dbo.Activity.Value, dbo.Unit.UId AS UnitUId, dbo.Unit.Name AS Unit
FROM         dbo.Activity INNER JOIN
                      dbo.Protocol ON dbo.Activity.Protocol_Fk = dbo.Protocol.UId INNER JOIN
                      dbo.EnzymeCode ON dbo.Activity.EnzymeCode_Fk = dbo.EnzymeCode.UId INNER JOIN
                      dbo.Material ON dbo.Activity.Material_Fk = dbo.Material.UId LEFT OUTER JOIN
                      dbo.Unit ON dbo.Activity.Unit_Fk = dbo.Unit.UId
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[41] 4[34] 2[7] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Activity"
            Begin Extent = 
               Top = 153
               Left = 385
               Bottom = 328
               Right = 545
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Protocol"
            Begin Extent = 
               Top = 43
               Left = 662
               Bottom = 197
               Right = 814
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "EnzymeCode"
            Begin Extent = 
               Top = 144
               Left = 66
               Bottom = 307
               Right = 218
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Material"
            Begin Extent = 
               Top = 9
               Left = 378
               Bottom = 90
               Right = 530
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Unit"
            Begin Extent = 
               Top = 206
               Left = 880
               Bottom = 303
               Right = 1032
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 10
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 2805
  ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ActivityView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N'       Alias = 4440
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ActivityView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ActivityView'
GO
/****** Objet :  View [dbo].[EnzymeView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[EnzymeView]
AS
SELECT     UId, Analyte, SlopeRatio, Code, Type
FROM         dbo.EnzymeCode
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "EnzymeCode"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 179
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'EnzymeView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'EnzymeView'
GO
/****** Objet :  StoredProcedure [dbo].[SelectProcessedData2]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
/****** Object:  Stored Procedure dbo.SelectProcessedData2    Script Date: 15.06.2006 14:50:14 ******/

CREATE  PROCEDURE [dbo].[SelectProcessedData2]
(
	@experiment nvarchar (50)
)
AS
	

SELECT     BatchCompilation.BatchName_Fk, BatchCompilation.BatchNumber_Fk, BatchCompilation.BatchDate_Fk, BatchCompilation.Experiment_Fk, 
                      BatchCompilation.Sample_Fk, BatchCompilation.Aliquot_Fk, ProcessedData.Enzyme_Fk, ProcessedData.Value, EnzymeCode.Analyte, EnzymeCode.Code, 
                      EnzymeCode.Type
FROM         ProcessedData INNER JOIN
                      EnzymeCode ON ProcessedData.Enzyme_Fk = EnzymeCode.UId INNER JOIN
                      BatchCompilation ON ProcessedData.BatchName_Fk = BatchCompilation.BatchName_Fk AND 
                      ProcessedData.BatchNumber_Fk = BatchCompilation.BatchNumber_Fk AND ProcessedData.BatchDate_Fk = BatchCompilation.BatchDate_Fk AND 
                      ProcessedData.Row_Fk = BatchCompilation.Row AND ProcessedData.Column_Fk = BatchCompilation.[Column] AND 
                      (
                      ProcessedData.Value >= 0
                      or
                      ProcessedData.Value is null
                      )
WHERE     (BatchCompilation.Experiment_Fk = @experiment)
GO
/****** Objet :  StoredProcedure [dbo].[InterBatchAvg]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
/****** Object:  Stored Procedure dbo.InterBatchAvg    Script Date: 15.06.2006 14:50:13 ******/

CREATE  PROCEDURE [dbo].[InterBatchAvg]
(
	@experiment nvarchar (50),
	@enzyme nvarchar (50)
)
AS

SELECT DISTINCT ProcessedData.BatchName_Fk, ProcessedData.BatchNumber_Fk, ProcessedData.BatchDate_Fk, AVG(ProcessedData.Value) AS Average
FROM         BatchCompilation INNER JOIN
                      ProcessedData ON BatchCompilation.BatchName_Fk = ProcessedData.BatchName_Fk AND BatchCompilation.BatchNumber_Fk = ProcessedData.BatchNumber_Fk AND
                       BatchCompilation.BatchDate_Fk = ProcessedData.BatchDate_Fk AND BatchCompilation.Row = ProcessedData.Row_Fk AND 
                      BatchCompilation.[Column] = ProcessedData.Column_Fk INNER JOIN
                      EnzymeCode ON ProcessedData.Enzyme_Fk = EnzymeCode.UId
WHERE     (BatchCompilation.Experiment_Fk = @experiment) AND (ProcessedData.Value >= 0) AND (ProcessedData.Value IS NOT NULL) AND (EnzymeCode.Analyte = @enzyme)
GROUP BY ProcessedData.BatchName_Fk, ProcessedData.BatchDate_Fk, ProcessedData.BatchNumber_Fk
GO
/****** Objet :  StoredProcedure [dbo].[UpdateEnzymeActivity]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.UpdateEnzymeActivity    Script Date: 15.06.2006 14:50:14 ******/
CREATE PROCEDURE [dbo].[UpdateEnzymeActivity]
(
	@Enzyme nvarchar (50),
	@Material nvarchar (50),
	@Value float,
	@Slope float,
	@OldEnzyme nvarchar (50)
)
AS

begin transaction
update dbo.EnzymeCodes set Enzyme = @Enzyme, SlopeRatio = @Slope where 
Enzyme = @OldEnzyme

update dbo.Activity set Value = @Value where EnzymeCode_Fk = @Enzyme and Material_Fk = @Material

commit transaction
GO
/****** Objet :  StoredProcedure [dbo].[DeleteEnzymeActivity]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.DeleteEnzymeActivity    Script Date: 15.06.2006 14:50:13 ******/
CREATE PROCEDURE [dbo].[DeleteEnzymeActivity]
(
	@Enzyme nvarchar (50),
	@Material nvarchar (50)
)
AS
	
delete from dbo.Activity where EnzymeCode_Fk = @Enzyme and Material_Fk = @Material
GO
/****** Objet :  StoredProcedure [dbo].[InsertEnzyme]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.InsertEnzymeActivity    Script Date: 15.06.2006 14:50:13 ******/
CREATE PROCEDURE [dbo].[InsertEnzyme]
(
	@Enzyme nvarchar(50),
	@Slope float,
	@Material nvarchar (50),
	@Val float
)
AS
	
Begin transaction

INSERT INTO EnzymeCodes
                      (Enzyme, SlopeRatio)
VALUES     (@Enzyme,@Slope)

INSERT INTO Activity
                      (EnzymeCode_Fk, Material_Fk, [Value])
VALUES     (@Enzyme,@Material, @Val)

commit transaction
GO
/****** Objet :  View [dbo].[BatchCompilationView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[BatchCompilationView]
AS
SELECT     dbo.Batches.UId AS BatchUId, dbo.Batches.Name AS BatchName, dbo.Batches.Number AS BatchNumber, dbo.Batches.Date AS BatchDate, 
                      dbo.Batches.[RowCount] AS BatchRowCount, dbo.Batches.ColumnCount AS BatchColumnCount, dbo.BatchCompilation.Experiment_Fk, 
                      dbo.BatchCompilation.Sample_Fk, dbo.BatchCompilation.Aliquot_Fk, dbo.BatchCompilation.Row, dbo.BatchCompilation.[Column], dbo.Batches.LayoutType
FROM         dbo.BatchCompilation INNER JOIN
                      dbo.Batches ON dbo.BatchCompilation.BatchName_Fk = dbo.Batches.Name AND dbo.BatchCompilation.BatchNumber_Fk = dbo.Batches.Number AND 
                      dbo.BatchCompilation.BatchDate_Fk = dbo.Batches.Date
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[41] 4[34] 2[6] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "BatchCompilation"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 250
               Right = 200
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Batches"
            Begin Extent = 
               Top = 11
               Left = 547
               Bottom = 269
               Right = 699
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 2295
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'BatchCompilationView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'BatchCompilationView'
GO
/****** Objet :  View [dbo].[BatchView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[BatchView]
AS
SELECT     dbo.Batches.Name, dbo.Batches.Number, dbo.Batches.Date, dbo.Batches.UId, dbo.Batches.LayoutType, dbo.Batches.[RowCount], dbo.Batches.ColumnCount, 
                      dbo.Batches.Protocol_Fk AS ProtocolUId, dbo.Protocol.Name AS ProtocolName, dbo.Protocol.Description AS ProtocolDescription
FROM         dbo.Batches INNER JOIN
                      dbo.Protocol ON dbo.Batches.Protocol_Fk = dbo.Protocol.UId
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[41] 4[31] 2[10] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Batches"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 201
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Protocol"
            Begin Extent = 
               Top = 110
               Left = 311
               Bottom = 206
               Right = 463
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'BatchView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'BatchView'
GO
/****** Objet :  View [dbo].[ExperimentView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ExperimentView]
AS
SELECT     UId, Id, Material_Fk
FROM         dbo.Experiments where Material_Fk is not null
union
SELECT     UId, Id, '00000000-0000-0000-0000-000000000000' as Material_Fk
FROM         dbo.Experiments  where Material_Fk is null
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Experiments"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 173
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ExperimentView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ExperimentView'
GO
/****** Objet :  View [dbo].[FreshWeightView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[FreshWeightView]
AS
SELECT     UId, ExperimentUId, ExperimentId, Sample, Material_Fk, Aliquot, Value,Location, 'in use' AS State
FROM         (SELECT     dbo.FreshWeights.UId, dbo.Experiments.UId AS ExperimentUId, dbo.Experiments.Id AS ExperimentId, dbo.Experiments.Material_Fk, 
                                              dbo.FreshWeights.Sample, dbo.FreshWeights.Aliquot, dbo.FreshWeights.Value, dbo.FreshWeights.Location
                       FROM          dbo.Experiments INNER JOIN
                                              dbo.FreshWeights ON dbo.Experiments.Id = dbo.FreshWeights.Experiment_Fk) a
WHERE     EXISTS
                          (SELECT DISTINCT Experiment_Fk, Sample_Fk, Aliquot_Fk
                            FROM          BatchCompilation
                            WHERE      (Experiment_Fk = a.ExperimentId) AND (Sample_Fk = a.Sample) AND (Aliquot_Fk = a.Aliquot))
UNION
SELECT     UId, ExperimentUId, ExperimentId, Sample, Material_Fk, Aliquot, Value,Location,  'free' AS State
FROM         (SELECT     dbo.FreshWeights.UId, dbo.Experiments.UId AS ExperimentUId, dbo.Experiments.Id AS ExperimentId, dbo.Experiments.Material_Fk, 
                                              dbo.FreshWeights.Sample, dbo.FreshWeights.Aliquot, dbo.FreshWeights.Value, dbo.FreshWeights.Location
                       FROM          dbo.Experiments INNER JOIN
                                              dbo.FreshWeights ON dbo.Experiments.Id = dbo.FreshWeights.Experiment_Fk) a
WHERE     (NOT EXISTS
                          (SELECT DISTINCT Experiment_Fk, Sample_Fk, Aliquot_Fk
                            FROM          BatchCompilation
                            WHERE      (Experiment_Fk = a.ExperimentId) AND (Sample_Fk = a.Sample) AND (Aliquot_Fk = a.Aliquot)))
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[10] 4[19] 2[54] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 10
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 3240
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FreshWeightView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FreshWeightView'
GO
/****** Objet :  StoredProcedure [dbo].[BatchRawDataAvg]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
/****** Object:  Stored Procedure dbo.BatchBlankAvg    Script Date: 15.06.2006 14:50:13 ******/

CREATE  PROCEDURE [dbo].[BatchRawDataAvg]
(
	@material uniqueidentifier,
	@enzyme uniqueidentifier,
	@velocity nvarchar(20)
)
AS


 select avg(RawValue) from dbo.RawData,
(
SELECT  BatchCompilation.BatchName_Fk, BatchCompilation.BatchNumber_Fk, BatchCompilation.BatchDate_Fk, Experiments.Id, FreshWeightView.Sample, FreshWeightView.Aliquot
, BatchCompilation.Row, BatchCompilation.[Column]
FROM         
FreshWeightView, Experiments, BatchCompilation

WHERE  
FreshWeightView.ExperimentUId = Experiments.UId and
FreshWeightView.ExperimentId = BatchCompilation.Experiment_Fk AND
FreshWeightView.[Sample] = BatchCompilation.Sample_Fk AND 
FreshWeightView.Aliquot = BatchCompilation.Aliquot_Fk 
 AND (Experiments.Material_Fk = @material)
) mat

 where RawData.BatchName_Fk = mat.BatchName_Fk
 and RawData.BatchNumber_Fk = mat.BatchNumber_Fk
 and RawData.BatchDate_Fk = mat.BatchDate_Fk
 and RawData.Row_Fk = mat.Row
 and RawData.Column_Fk = mat.[Column]
 and Enzyme_Fk = @enzyme
 and Velocity = @velocity
 and excluded = 0
 and proved = 1
GO
/****** Objet :  View [dbo].[AllAssaysControlValues]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  View dbo.AllAssaysControlValues    Script Date: 15.06.2006 14:50:13 ******/
CREATE VIEW [dbo].[AllAssaysControlValues]
AS
SELECT     dbo.ProcessedData.BatchName_Fk, dbo.ProcessedData.BatchNumber_Fk, dbo.ProcessedData.BatchDate_Fk, dbo.ProcessedData.Enzyme_Fk, 
                      dbo.ProcessedData.[Value]
FROM         dbo.ProcessedData INNER JOIN
                      dbo.BatchCompilation ON dbo.ProcessedData.BatchName_Fk = dbo.BatchCompilation.BatchName_Fk AND 
                      dbo.ProcessedData.BatchNumber_Fk = dbo.BatchCompilation.BatchNumber_Fk AND 
                      dbo.ProcessedData.BatchDate_Fk = dbo.BatchCompilation.BatchDate_Fk AND dbo.ProcessedData.Row_Fk = dbo.BatchCompilation.Row AND 
                      dbo.ProcessedData.Column_Fk = dbo.BatchCompilation.[Column] INNER JOIN
                      dbo.Experiments ON dbo.BatchCompilation.Experiment_Fk = dbo.Experiments.Id
WHERE     (dbo.Experiments.Material_Fk IS NOT NULL) AND (dbo.ProcessedData.[Value] IS NOT NULL)
GO
/****** Objet :  StoredProcedure [dbo].[AvailableAnalytes]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[AvailableAnalytes]
	-- Add the parameters for the stored procedure here
	@experiment nvarchar(50),
	@sample	int,
	@aliquot int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT     ProcessedData.Enzyme_Fk
FROM         BatchCompilation INNER JOIN
                      ProcessedData ON BatchCompilation.BatchName_Fk = ProcessedData.BatchName_Fk AND 
                      BatchCompilation.BatchNumber_Fk = ProcessedData.BatchNumber_Fk AND BatchCompilation.BatchDate_Fk = ProcessedData.BatchDate_Fk AND 
                      BatchCompilation.Row = ProcessedData.Row_Fk AND BatchCompilation.[Column] = ProcessedData.Column_Fk
WHERE     (BatchCompilation.Experiment_Fk = @experiment) AND (BatchCompilation.Sample_Fk = @sample) AND (BatchCompilation.Aliquot_Fk = @aliquot)
END
GO
/****** Objet :  StoredProcedure [dbo].[SelectProcessedData]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.SelectProcessedData    Script Date: 15.06.2006 14:50:14 ******/

CREATE  PROCEDURE [dbo].[SelectProcessedData]
(
	@experiment nvarchar (50)
)
AS
	


sELECT  BatchCompilation.BatchName_Fk  + '-' + cast(BatchCompilation.BatchNumber_Fk as varchar(20)) + '-' + convert (varchar(30), BatchCompilation.BatchDate_Fk, 1 )  as batName, 
 BatchCompilation.Experiment_Fk, BatchCompilation.Sample_Fk, Aliquot_Fk,ProcessedData.Enzyme_Fk,  ProcessedData.Value  
FROM         ProcessedData INNER JOIN
                      BatchCompilation ON ProcessedData.BatchName_Fk = BatchCompilation.BatchName_Fk AND 
                      ProcessedData.BatchNumber_Fk = BatchCompilation.BatchNumber_Fk AND ProcessedData.BatchDate_Fk = BatchCompilation.BatchDate_Fk AND 
                      ProcessedData.Row_Fk = BatchCompilation.Row AND ProcessedData.Column_Fk = BatchCompilation.[Column]
		      and Value >= 0
WHERE     (BatchCompilation.Experiment_Fk = @experiment )
GO
/****** Objet :  StoredProcedure [dbo].[SingleProcessedData]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[SingleProcessedData]
	-- Add the parameters for the stored procedure here
	@experiment nvarchar (50),
	@sample int,
	@aliquot int,
	@enzyme nvarchar (50)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT     ProcessedData.Value
	FROM         ProcessedData INNER JOIN BatchCompilation ON 
	ProcessedData.BatchName_Fk = BatchCompilation.BatchName_Fk AND 
	ProcessedData.BatchNumber_Fk = BatchCompilation.BatchNumber_Fk AND 
	ProcessedData.BatchDate_Fk = BatchCompilation.BatchDate_Fk AND 
	ProcessedData.Row_Fk = BatchCompilation.Row AND 
	ProcessedData.Column_Fk = BatchCompilation.[Column] 
	WHERE
	(BatchCompilation.Experiment_Fk = @experiment) AND 
	(BatchCompilation.Sample_Fk = @sample) AND 
	(BatchCompilation.Aliquot_Fk = @aliquot)AND 
	(ProcessedData.Enzyme_Fk = @enzyme) --AND
	--ProcessedData.Value >= 0
END
GO
/****** Objet :  View [dbo].[ProtocolView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ProtocolView]
AS
SELECT     UId, Name, Description, Enzyme_FK
FROM         dbo.Protocol
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Protocol"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 102
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ProtocolView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ProtocolView'
GO
/****** Objet :  View [dbo].[MaterialView]    Date de génération du script : 09/23/2013 11:46:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[MaterialView]
AS
SELECT     UId, Name
FROM         dbo.Material
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Material"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 87
               Right = 190
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MaterialView'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MaterialView'
GO
/****** Objet :  Check [CK_Batches]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Batches]  WITH CHECK ADD  CONSTRAINT [CK_Batches] CHECK  (([LayoutType]='FULL' OR [LayoutType]='SPLIT'))
GO
ALTER TABLE [dbo].[Batches] CHECK CONSTRAINT [CK_Batches]
GO
/****** Objet :  Check [CK_EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[EnzymeCode]  WITH CHECK ADD  CONSTRAINT [CK_EnzymeCode] CHECK  (([Type]='Metabolite' OR [Type]='Enzyme'))
GO
ALTER TABLE [dbo].[EnzymeCode] CHECK CONSTRAINT [CK_EnzymeCode]
GO
/****** Objet :  Check [CK_RawData]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[RawData]  WITH CHECK ADD  CONSTRAINT [CK_RawData] CHECK  (([Velocity]='max' OR [Velocity]='blank' OR [Velocity]='NA'))
GO
ALTER TABLE [dbo].[RawData] CHECK CONSTRAINT [CK_RawData]
GO
/****** Objet :  ForeignKey [FK_Activity_EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Activity]  WITH CHECK ADD  CONSTRAINT [FK_Activity_EnzymeCode] FOREIGN KEY([EnzymeCode_Fk])
REFERENCES [dbo].[EnzymeCode] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Activity] CHECK CONSTRAINT [FK_Activity_EnzymeCode]
GO
/****** Objet :  ForeignKey [FK_Activity_Material]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Activity]  WITH CHECK ADD  CONSTRAINT [FK_Activity_Material] FOREIGN KEY([Material_Fk])
REFERENCES [dbo].[Material] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Activity] CHECK CONSTRAINT [FK_Activity_Material]
GO
/****** Objet :  ForeignKey [FK_Activity_Protocol]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Activity]  WITH CHECK ADD  CONSTRAINT [FK_Activity_Protocol] FOREIGN KEY([Protocol_Fk])
REFERENCES [dbo].[Protocol] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Activity] CHECK CONSTRAINT [FK_Activity_Protocol]
GO
/****** Objet :  ForeignKey [FK_Activity_Unit]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Activity]  WITH CHECK ADD  CONSTRAINT [FK_Activity_Unit] FOREIGN KEY([Unit_Fk])
REFERENCES [dbo].[Unit] ([UId])
ON UPDATE CASCADE
ON DELETE SET NULL
GO
ALTER TABLE [dbo].[Activity] CHECK CONSTRAINT [FK_Activity_Unit]
GO
/****** Objet :  ForeignKey [FK_BatchCompilation_Batches]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[BatchCompilation]  WITH CHECK ADD  CONSTRAINT [FK_BatchCompilation_Batches] FOREIGN KEY([BatchName_Fk], [BatchNumber_Fk], [BatchDate_Fk])
REFERENCES [dbo].[Batches] ([Name], [Number], [Date])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[BatchCompilation] CHECK CONSTRAINT [FK_BatchCompilation_Batches]
GO
/****** Objet :  ForeignKey [FK_BatchCompilation_FreshWeights]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[BatchCompilation]  WITH CHECK ADD  CONSTRAINT [FK_BatchCompilation_FreshWeights] FOREIGN KEY([Experiment_Fk], [Sample_Fk], [Aliquot_Fk])
REFERENCES [dbo].[FreshWeights] ([Experiment_FK], [Sample], [Aliquot])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[BatchCompilation] CHECK CONSTRAINT [FK_BatchCompilation_FreshWeights]
GO
/****** Objet :  ForeignKey [FK_Batches_Protocol]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Batches]  WITH CHECK ADD  CONSTRAINT [FK_Batches_Protocol] FOREIGN KEY([Protocol_Fk])
REFERENCES [dbo].[Protocol] ([UId])
ON DELETE SET DEFAULT
GO
ALTER TABLE [dbo].[Batches] CHECK CONSTRAINT [FK_Batches_Protocol]
GO
/****** Objet :  ForeignKey [FK_Experiments_Material]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Experiments]  WITH CHECK ADD  CONSTRAINT [FK_Experiments_Material] FOREIGN KEY([Material_Fk])
REFERENCES [dbo].[Material] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Experiments] CHECK CONSTRAINT [FK_Experiments_Material]
GO
/****** Objet :  ForeignKey [FK_FreshWeights_Experiments]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[FreshWeights]  WITH CHECK ADD  CONSTRAINT [FK_FreshWeights_Experiments] FOREIGN KEY([Experiment_FK])
REFERENCES [dbo].[Experiments] ([Id])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[FreshWeights] CHECK CONSTRAINT [FK_FreshWeights_Experiments]
GO
/****** Objet :  ForeignKey [FK_ProcessedData_BatchCompilation]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[ProcessedData]  WITH CHECK ADD  CONSTRAINT [FK_ProcessedData_BatchCompilation] FOREIGN KEY([BatchName_Fk], [BatchNumber_Fk], [BatchDate_Fk], [Row_Fk], [Column_Fk])
REFERENCES [dbo].[BatchCompilation] ([BatchName_Fk], [BatchNumber_Fk], [BatchDate_Fk], [Row], [Column])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ProcessedData] CHECK CONSTRAINT [FK_ProcessedData_BatchCompilation]
GO
/****** Objet :  ForeignKey [FK_ProcessedData_EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[ProcessedData]  WITH CHECK ADD  CONSTRAINT [FK_ProcessedData_EnzymeCode] FOREIGN KEY([Enzyme_Fk])
REFERENCES [dbo].[EnzymeCode] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ProcessedData] CHECK CONSTRAINT [FK_ProcessedData_EnzymeCode]
GO
/****** Objet :  ForeignKey [FK_Protocol_EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[Protocol]  WITH CHECK ADD  CONSTRAINT [FK_Protocol_EnzymeCode] FOREIGN KEY([Enzyme_Fk])
REFERENCES [dbo].[EnzymeCode] ([UId])
GO
ALTER TABLE [dbo].[Protocol] CHECK CONSTRAINT [FK_Protocol_EnzymeCode]
GO
/****** Objet :  ForeignKey [FK_ProtocolSetting_Parameter]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[ProtocolSetting]  WITH CHECK ADD  CONSTRAINT [FK_ProtocolSetting_Parameter] FOREIGN KEY([Parameter_Fk])
REFERENCES [dbo].[Parameter] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ProtocolSetting] CHECK CONSTRAINT [FK_ProtocolSetting_Parameter]
GO
/****** Objet :  ForeignKey [FK_ProtocolSetting_Protocol]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[ProtocolSetting]  WITH CHECK ADD  CONSTRAINT [FK_ProtocolSetting_Protocol] FOREIGN KEY([Protocol_Fk])
REFERENCES [dbo].[Protocol] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ProtocolSetting] CHECK CONSTRAINT [FK_ProtocolSetting_Protocol]
GO
/****** Objet :  ForeignKey [FK_RawData_BatchCompilation]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[RawData]  WITH CHECK ADD  CONSTRAINT [FK_RawData_BatchCompilation] FOREIGN KEY([BatchName_Fk], [BatchNumber_Fk], [BatchDate_Fk], [Row_Fk], [Column_Fk])
REFERENCES [dbo].[BatchCompilation] ([BatchName_Fk], [BatchNumber_Fk], [BatchDate_Fk], [Row], [Column])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RawData] CHECK CONSTRAINT [FK_RawData_BatchCompilation]
GO
/****** Objet :  ForeignKey [FK_RawData_EnzymeCode]    Date de génération du script : 09/23/2013 11:46:31 ******/
ALTER TABLE [dbo].[RawData]  WITH CHECK ADD  CONSTRAINT [FK_RawData_EnzymeCode] FOREIGN KEY([Enzyme_Fk])
REFERENCES [dbo].[EnzymeCode] ([UId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RawData] CHECK CONSTRAINT [FK_RawData_EnzymeCode]
GO
